import { PrismaClient } from '@prisma/client'

const prisma = new PrismaClient()

async function main(): Promise<void> {
  const users = await prisma.user.findMany({
    orderBy: { createdAt: 'desc' },
    take: 10,
    include: {
      stakingInfo: true
    }
  })

  users.forEach((user) => {
    const staking = user.stakingInfo
    console.log({
      id: user.id,
      idNumber: user.idNumber,
      tier: user.tier,
      createdAt: user.createdAt.toISOString(),
      stakedAmount: staking ? Number(staking.stakedAmount) : 0,
      dailyRewardRate: staking ? Number(staking.dailyRewardRate) : 0,
      currentDailyReward: staking ? Number(staking.currentDailyReward) : 0,
      totalRewardsNear: staking ? Number(staking.totalRewardsNear) : 0
    })
  })
}

main()
  .catch((error) => {
    console.error(error)
    process.exitCode = 1
  })
  .finally(async () => {
    await prisma.$disconnect()
  })
